// enlistList
exports.enlistList = function (req, res) {

    //获取restful参数
    var restfulParams = req.routeInfo.restfulParams;

    var resultData = {};

    var skip = restfulParams.skip == undefined ? 0 : restfulParams.skip;

    var limit = restfulParams.limit == undefined ? config.publicConfig.LIMIT : restfulParams.limit;

    var orderType = restfulParams.order_type;

    var orderInfo = 0;

    //任务流创建
    async.waterfall([

        //获取机构列表
        function (cb) {

            var url = 0;
            if (orderType == 5) {
                //促销
                url = CORE_APIConfig.coreAPI.search_order + "/o_type/0/o_activity_type/5/o_oid/" + restfulParams.o_id + "/o_aoc_id/" + restfulParams.oaid + "/sort_order/o_create_time-desc/skip/" + skip + "/limit/" + limit;
            } else if (orderType == 0) {
                //拼团
                url = CORE_APIConfig.coreAPI.searchBulkPurchaseOrder + "/o_oid/" + restfulParams.o_id + "/bpau_oaid/" + restfulParams.oaid + "/sort_order/bpau_join_time-desc/skip/" + skip + "/limit/" + limit;
            } else if (orderType == 2) {
                //砍价
                url = CORE_APIConfig.coreAPI.searchBargainJoinAndActivityInfo + "/bj_oaid/" + restfulParams.oaid + "/sort_order/bj_create_time-desc/skip/" + skip + "/limit/" + limit;
            } else if (orderType == 1) {
                //投票
                url = CORE_APIConfig.coreAPI.search_order + "/o_type/0/o_activity_type/1/o_oid/" + restfulParams.o_id + "/o_aoc_id/" + restfulParams.oaid + "/sort_order/o_create_time-desc/skip/" + skip + "/limit/" + limit;
            }

            console.log(url);

            R.SEND_HTTP(
                req,
                {
                    url: url,
                    method: 'POST',
                },
                function (err, data) {

                    orderInfo = data.data;

                    cb();
                }
            );

        },

        function (cb) {
            /*if (orderType == 5) {
                //促销
                resultData.orderInfo = orderInfo;
                cb()
            }else if(orderType == 0){
                //拼团
                resultData.orderInfo = orderInfo;
                cb()
            }else if(orderType == 2){
                //砍价
                resultData.orderInfo = orderInfo;
                cb()
            }else if(orderType == 1){
                //投票
                resultData.orderInfo = orderInfo;
                cb()
            }*/
            resultData.orderInfo = orderInfo;
            cb();
        },

        function (cb) {
            if (orderType == 5) {

                R.SEND_HTTP(
                    req,
                    {
                        url: CORE_APIConfig.coreAPI.searchDiscountsActivityUserSearch + "/dau_oaid/" + restfulParams.oaid,
                        method: 'GET'
                    },
                    function (err, data) {

                        resultData.freeList = data.data;

                        cb();
                    }
                );

            }
            cb();
        }
    ], function (err, result) {

        //返回最终拼接结果
        RES.response(res, true, resultData);

    });
}